﻿using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TRACv2.Domain.Entities;

//Author: Morgan William Davis III
//Project: TRAC Ticket Manager v2
//Date: 21 Mar 2014

namespace TRACv2.Domain.Test
{
    [TestClass]
    [ExcludeFromCodeCoverage]
    public class EmployeeTest
    {
        #region [ Field used for testing Employee Validation ]

        private readonly Employee _testEmployee = new Employee
        {
            ID = 1, PersonID = 1, FirstName = "Bob", 
            LastName = "Tabor", PositionID = 1, 
            Department = "IT", StartDate = DateTime.Now, 
            Code = "testCode" 
        };

        #endregion

        #region [ Set Property Accessors ]

        #region [ ID and PositionID Properties ]

        [TestMethod]
        public void ID_IntegerLessThanOne_ShouldNotValidate()
        {   
            //Arrange
            var thisEmployee = _testEmployee;
            bool exceptionCatch = false;
            //Act
            try
            {
                thisEmployee.ID = 0;
            }
            catch (Exception)
            {

                exceptionCatch = true;
            }

            //Assert
            Assert.IsTrue(exceptionCatch);       
        }

        [TestMethod]
        public void PositionID_IntegerLessThanOne_ShouldNotValidate()
        {
            //Arrange
            var thisEmployee = _testEmployee;
            bool exceptionCatch = false;
            //Act
            try
            {
                thisEmployee.PositionID = 0;
            }
            catch (Exception)
            {

                exceptionCatch = true;
            }

            //Assert
            Assert.IsTrue(exceptionCatch);
        }

        #endregion

        #region [ FirstName Property ]

        [TestMethod]
        public void FirstName_StringIsNull_ShouldNotValidate()
        {
            //Arrange
            var thisEmployee = _testEmployee;
            bool exceptionCatch = false;
            //Act
            try
            {
                thisEmployee.FirstName = null;
            }
            catch (Exception)
            {

                exceptionCatch = true;
            }

            //Assert
            Assert.IsTrue(exceptionCatch);
        }

        [TestMethod]
        public void FirstName_StringIsEmpty_ShouldNotValidate()
        {
            //Arrange
            var thisEmployee = _testEmployee;
            bool exceptionCatch = false;
            //Act
            try
            {
                thisEmployee.FirstName = "";
            }
            catch (Exception)
            {

                exceptionCatch = true;
            }

            //Assert
            Assert.IsTrue(exceptionCatch);
        }

        #endregion

        #region [LastName Property ]

        [TestMethod]
        public void LastName_StringIsNull_ShouldNotValidate()
        {
            //Arrange
            var thisEmployee = _testEmployee;
            bool exceptionCatch = false;
            //Act
            try
            {
                thisEmployee.LastName = null;
            }
            catch (Exception)
            {

                exceptionCatch = true;
            }

            //Assert
            Assert.IsTrue(exceptionCatch);
        }

        [TestMethod]
        public void LastName_StringIsEmpty_ShouldNotValidate()
        {
            //Arrange
            var thisEmployee = _testEmployee;
            bool exceptionCatch = false;
            //Act
            try
            {
                thisEmployee.LastName = "";
            }
            catch (Exception)
            {

                exceptionCatch = true;
            }

            //Assert
            Assert.IsTrue(exceptionCatch);
        }

        #endregion

        #region [ Code Properties ]

        [TestMethod]
        public void Code_StringIsEmpty_ShouldNotValidate()
        {
            //Arrange
            var thisEmployee = _testEmployee;
            bool exceptionCatch = false;
            //Act
            try
            {
                thisEmployee.Code = "";
            }
            catch (Exception)
            {

                exceptionCatch = true;
            }

            //Assert
            Assert.IsTrue(exceptionCatch);
        }

        [TestMethod]
        public void Code_StringIsNull_ShouldNotValidate()
        {
            //Arrange
            var thisEmployee = _testEmployee;
            bool exceptionCatch = false;
            //Act
            try
            {
                thisEmployee.Code = null;
            }
            catch (Exception)
            {

                exceptionCatch = true;
            }

            //Assert
            Assert.IsTrue(exceptionCatch);
        }

        #endregion

        #endregion

        #region [ Get Property Accessors ]

        [TestMethod]
        public void ID_GetValue_ShouldReturnExpected()
        {
            //Arrange and Act
            const int comparisonId = 1;
            var boolCheck = comparisonId == _testEmployee.ID;

            //Assert
            Assert.IsTrue(boolCheck);
        }

        [TestMethod]
        public void PersonID_GetValue_ShouldReturnExpected()
        {
            //Arrange and Act
            const int comparisonId = 1;
            var boolCheck = comparisonId == _testEmployee.PersonID;

            //Assert
            Assert.IsTrue(boolCheck);
        }

        [TestMethod]
        public void PositionID_GetValue_ShouldReturnExpected()
        {
            //Arrange and Act
            const int comparisonId = 1;
            var boolCheck = comparisonId == _testEmployee.PositionID;

            //Assert
            Assert.IsTrue(boolCheck);
        }

        [TestMethod]
        public void FirstName_GetValue_ShouldReturnExpected()
        {
            //Arrange and Act
            const string comparisonString = "Bob";
            var boolCheck = comparisonString == _testEmployee.FirstName;

            //Assert
            Assert.IsTrue(boolCheck);
        }

        [TestMethod]
        public void LastName_GetValue_ShouldReturnExpected()
        {
            //Arrange and Act
            const string comparisonString = "Tabor";
            var boolCheck = comparisonString == _testEmployee.LastName;

            //Assert
            Assert.IsTrue(boolCheck);
        }

        [TestMethod]
        public void Department_GetValue_ShouldReturnExpected()
        {
            //Arrange and Act
            const string comparisonString = "IT";
            var boolCheck = comparisonString == _testEmployee.Department;

            //Assert
            Assert.IsTrue(boolCheck);
        }

        [TestMethod]
        public void StartDate_GetValue_ShouldReturnExpected()
        {
            //Arrange and Act
            DateTime comparisonDate = DateTime.Now;
            var boolCheck = comparisonDate == _testEmployee.StartDate;

            //Assert
            Assert.IsTrue(boolCheck);
        }

        [TestMethod]
        public void Code_GetValue_ShouldReturnExpected()
        {
            //Arrange and Act
            const string comparisonString = "testCode";
            var boolCheck = comparisonString == _testEmployee.Code;

            //Assert
            Assert.IsTrue(boolCheck);
        }

        #endregion
    }
}
